<?php

namespace app\admin\service;

use support\spark\model\order\OrderComment;
class AppraiseService
{

    /**
     * 获取评价列表
     * @param $param
     * @return array
     */
    public function getList($param)
    {
        $limit = $param['limit'];
        $type = $param['type'];
        $appraiseTime = $param['create_time'];

        $where = [];
        if (!empty($type)) {
            $where[] = ['type', '=', $type];
        }

        if (!empty($appraiseTime)) {
            $where[] = ['create_time', 'between', [$appraiseTime[0] . ' 00:00:00', $appraiseTime[1] . ' 23:59:59']];
        }

        $appraise = config('shop.appraise');
        $commentModel = new OrderComment();
        $list=$commentModel->getPaginateList($where,['*'],['id'=>'desc'],[],$limit);
        foreach ($list['data'] as $key=>$item){
            $list['data'][$key]['type']=$appraise[$item['type']];
        }

        return dataReturn(0, 'success', $list);
    }
}